<?php 
namespace Home\Model;
use Think\Model;
class UserInfoModel extends Model 
{
    public function addUserInfo($sleepingId, $form)
    {
        $add = array(
            'sleeping_id'   =>  $sleepingId,
            'name'          =>  $form['name'],
            'address'       =>  $form['address'],
            'phone'         =>  $form['phone'],
            'ip'            =>  $_SERVER["REMOTE_ADDR"]
        );
        return $this->add($add);
    }
    public function hasSidUserInfo($sleepingId)
    {
        $where = array(
            'sleeping_id'   =>  $sleepingId,
        );
        return $this->where($where)->find();
    }
    public function getUserInfoList($limit)
    {
        if(!empty($result))
            return $result;
        $field = array(
            'name',
            'sleeping_id',
            'phone',
            'address'
        );
        $result = $this->field($field)->limit($limit)->select();
        return $result;
    }
}
